package com.shouhuobao.bhi.receiver;

import java.util.ArrayList;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.collectplus.express.R;
import com.collectplus.express.model.LocationBean;
import com.collectplus.express.model.SameCityHistoryBean;

import droid.frame.activity.base.BaseAdapterExt;

/**
 * 寄件人、选择地址
 * 
 * @author coffee <br>
 *         2016-11-14下午2:53:38
 */
public class ReceiverLocationAdapter extends BaseAdapterExt<SameCityHistoryBean> {

	public ReceiverLocationAdapter(ArrayList<SameCityHistoryBean> items, Activity context) {
		super(items, context);
	}

	@Override
	public int getCount() {
		// return Math.min(super.getCount(), 6);
		return super.getCount();
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder;
		if (convertView == null) {
			holder = new ViewHolder();
			convertView = LayoutInflater.from(context).inflate(R.layout.receiver_location_item, parent, false);
			holder.name = (TextView) convertView.findViewById(R.id.receiver_location_name);
			holder.desc = (TextView) convertView.findViewById(R.id.receiver_location_desc);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		SameCityHistoryBean item = getItem(position);
		holder.name.setText(item.getBuildName());
		holder.desc.setText(item.getAddress());
		return convertView;
	}

	private class ViewHolder {
		TextView name;// 地址名
		TextView desc;// 地址详细信息
	}

}
